
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>flutter配置 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="flutter语法.html" />
    
    
    <link rel="prev" href="../" />
    

    
        <link rel="shortcut icon" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    个人信息
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="flutter配置.html">
            
                <a href="flutter配置.html">
            
                    
                    flutter配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="flutter语法.html">
            
                <a href="flutter语法.html">
            
                    
                    flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="flutter控件.html">
            
                <a href="flutter控件.html">
            
                    
                    flutter控件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="flutter第三方库.html">
            
                <a href="flutter第三方库.html">
            
                    
                    flutter第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="flutter异常.html">
            
                <a href="flutter异常.html">
            
                    
                    flutter异常
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >flutter配置</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#flutter&#x914D;&#x7F6E;"><b>1. </b>flutter&#x914D;&#x7F6E;</a></li><ul><li><span class="title-icon "></span><a href="#app-&#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;"><b>1.1. </b>app &#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x7528;-bloc-&#x6A21;&#x5F0F;"><b>1.2. </b>flutter &#x7528; BloC &#x6A21;&#x5F0F;</a></li><li><span class="title-icon "></span><a href="#&#x9879;&#x76EE;&#x7C7B;&#x578B;"><b>1.3. </b>&#x9879;&#x76EE;&#x7C7B;&#x578B;</a></li><ul><li><span class="title-icon "></span><a href="#flutter-application"><b>1.3.1. </b>Flutter Application</a></li><li><span class="title-icon "></span><a href="#flutter-plugin"><b>1.3.2. </b>Flutter Plugin</a></li><li><span class="title-icon "></span><a href="#flutter-package"><b>1.3.3. </b>Flutter Package</a></li><li><span class="title-icon "></span><a href="#flutter-module"><b>1.3.4. </b>Flutter Module</a></li></ul><li><span class="title-icon "></span><a href="#json"><b>1.4. </b>json</a></li><li><span class="title-icon "></span><a href="#&#x7B7E;&#x540D;&#x914D;&#x7F6E;-keystore"><b>1.5. </b>&#x7B7E;&#x540D;&#x914D;&#x7F6E; keystore</a></li><li><span class="title-icon "></span><a href="#&#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;"><b>1.6. </b>&#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;</a></li><li><span class="title-icon "></span><a href="#flutter&#x5DE5;&#x7A0B;&#x4E2D;-android&#x90E8;&#x5206;&#x7206;&#x7EA2;"><b>1.7. </b>flutter&#x5DE5;&#x7A0B;&#x4E2D; Android&#x90E8;&#x5206;&#x7206;&#x7EA2;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;-android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;"><b>1.8. </b>flutter &#x63D2;&#x4EF6;&#x5F00;&#x53D1; Android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x4E0E;-android-&#x6570;&#x636E;-&#x4EA4;&#x4E92;"><b>1.9. </b>flutter &#x4E0E; Android &#x6570;&#x636E; &#x4EA4;&#x4E92;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;"><b>1.10. </b>flutter &#x63D2;&#x4EF6;&#x5F00;&#x53D1;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x8C03;&#x7528;android&#x63A7;&#x4EF6;"><b>1.11. </b>flutter &#x8C03;&#x7528;Android&#x63A7;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#&#x56FD;&#x9645;&#x5316;-&#x7FFB;&#x8BD1;&#x652F;&#x6301;"><b>1.12. </b>&#x56FD;&#x9645;&#x5316; &#x7FFB;&#x8BD1;&#x652F;&#x6301;</a></li><ul><li><span class="title-icon "></span><a href="#&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6;-&#x56FD;&#x9645;&#x5316;"><b>1.12.1. </b>&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6; &#x56FD;&#x9645;&#x5316;</a></li><li><span class="title-icon "></span><a href="#&#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A;-&#x56FD;&#x9645;&#x5316;"><b>1.12.2. </b>&#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A; &#x56FD;&#x9645;&#x5316;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5C4F;&#x5E55;&#x9002;&#x914D;"><b>1.13. </b>&#x5C4F;&#x5E55;&#x9002;&#x914D;</a></li><li><span class="title-icon "></span><a href="#flutter-&#x8FD0;&#x884C;&#x6A21;&#x5F0F;"><b>1.14. </b>flutter &#x8FD0;&#x884C;&#x6A21;&#x5F0F;</a></li><li><span class="title-icon "></span><a href="#&#x72B6;&#x6001;&#x7BA1;&#x7406;"><b>1.15. </b>&#x72B6;&#x6001;&#x7BA1;&#x7406;</a></li></ul></ul></div><a href="#flutter&#x914D;&#x7F6E;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="flutter&#x914D;&#x7F6E;"><a name="flutter&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#flutter&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1. flutter&#x914D;&#x7F6E;</h1>
<pre><code class="lang-text">1&#x3001;&#x4FEE;&#x6539;&#x6574;&#x4E2A;&#x5DE5;&#x7A0B;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x540D;&#x5B57;&#xFF0C;  &#x4FEE;&#x6539;&#x540E;&#x9700;&#x8981;&#x5728;&#x5DE5;&#x7A0B;&#x91CC; &#x91CD;&#x65B0;&#x547D;&#x540D;xxx.imld&#x7684;&#x540D;&#x5B57;&#xFF08;&#x4F8B;&#x5982; wk-weather.iml &#xFF09;

2&#x3001;&#x7248;&#x672C;&#x53F7;&#x5728; pubspec.yaml version &#x4E2D;&#x914D;&#x7F6E;  
version: 1.0.20201109+1   1.0.20201109 &#x662F;&#x7248;&#x672C;&#x6807;&#x8BB0; &#xFF0C; 1&#x662F;&#x7248;&#x672C;&#x53F7;

3&#x3001;&#x9690;&#x85CF;&#x53F3;&#x4E0A;&#x89D2; debug &#x6807;&#x8BB0;
debugShowCheckedModeBanner: false,
</code></pre>
<h2 id="app-&#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;"><a name="app-&#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;" class="anchor-navigation-ex-anchor" href="#app-&#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. app &#x663E;&#x793A;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;&#x754C;&#x9762;</h2>
<pre><code class="lang-text">import &apos;package:flutter/rendering.dart&apos;;
void main() {
  debugPaintSizeEnabled = true;
  runApp(  ) ;
}
</code></pre>
<h2 id="flutter-&#x7528;-bloc-&#x6A21;&#x5F0F;"><a name="flutter-&#x7528;-bloc-&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#flutter-&#x7528;-bloc-&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. flutter &#x7528; BloC &#x6A21;&#x5F0F;</h2>
<pre><code class="lang-text">&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x7EC4;&#x4EF6; &#xFF08;Business Logic Component &#xFF09;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;BloC&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;&#xFF0C;&#x4F3C;&#x4E4E;&#x548C;MVP&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x672C;&#x8D28;&#x533A;&#x522B;&#xFF0C;
&#x4E24;&#x79CD;&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;&#x7684;&#x6700;&#x7EC8;&#x76EE;&#x7684;&#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x628A;&#x548C;UI&#x7CC5;&#x5408;&#x5728;&#x4E00;&#x8D77;&#x7684;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x4EE3;&#x7801;&#x5265;&#x79BB;&#x5F00;&#x6765;&#xFF0C;&#x5355;&#x72EC;&#x7684;&#x62BD;&#x53D6;&#x5230;&#x4E00;&#x5C42;&#x4E2D;&#x3002;
</code></pre>
<h2 id="&#x9879;&#x76EE;&#x7C7B;&#x578B;"><a name="&#x9879;&#x76EE;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x9879;&#x76EE;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x9879;&#x76EE;&#x7C7B;&#x578B;</h2>
<h3 id="flutter-application"><a name="flutter-application" class="anchor-navigation-ex-anchor" href="#flutter-application"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1. Flutter Application</h3>
<pre><code class="lang-text">Flutter Application &#x8868;&#x793A;&#x4E00;&#x4E2A;Flutter&#x9879;&#x76EE;&#xFF0C;&#x4E3B;&#x4F53;&#x662F;Flutter&#xFF0C;
&#x5F53;&#x7136;&#x5B83;&#x4E5F;&#x53EF;&#x4EE5;&#x63A5;&#x5165;Android Module &#x6216;&#x8005; iOS Framework&#xFF0C;
&#x5176;&#x5185;&#x90E8;&#x5305;&#x542B; Android &#x548C; iOS &#x9879;&#x76EE;&#x3002;&#x4EE5;&#x540E;&#x53EF;&#x80FD;&#x4F1A;&#x652F;&#x6301;&#x5176;&#x4ED6;&#x5E73;&#x53F0;&#x3002;
</code></pre>
<h3 id="flutter-plugin"><a name="flutter-plugin" class="anchor-navigation-ex-anchor" href="#flutter-plugin"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.2. Flutter Plugin</h3>
<pre><code class="lang-text">Flutter Plugin &#x8868;&#x793A; Flutter &#x63D2;&#x4EF6;&#xFF0C;&#x5305;&#x542B; Android &#x548C; iOS &#x9879;&#x76EE;&#xFF0C;
&#x5982;&#x679C;&#x4F60;&#x8981;&#x5F00;&#x53D1;&#x4E00;&#x4E2A; Plugin &#x4E14;&#x6B64; Plugin &#x6D89;&#x53CA;&#x5230;&#x539F;&#x751F;&#x652F;&#x6301;&#xFF0C;&#x6BD4;&#x5982;&#x84DD;&#x7259;&#x529F;&#x80FD;&#x3001;&#x7F51;&#x7EDC;&#x529F;&#x80FD;&#x7B49;&#xFF0C;
&#x8FD9;&#x4E9B;&#x529F;&#x80FD;&#x7EAF; Flutter &#x662F;&#x65E0;&#x6CD5;&#x5B9E;&#x73B0;&#x7684;&#x3002;

Flutter Plugin &#x5F00;&#x53D1;&#x5B8C;&#x6210;&#x540E;&#x53EF;&#x4EE5;&#x53D1;&#x5E03;&#x5230; pub &#x4E0A;&#x3002;
</code></pre>
<h3 id="flutter-package"><a name="flutter-package" class="anchor-navigation-ex-anchor" href="#flutter-package"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.3. Flutter Package</h3>
<pre><code class="lang-text">Flutter Package &#x548C; Flutter Plugin &#x57FA;&#x672C;&#x4E00;&#x6837;&#xFF0C;&#x552F;&#x4E00;&#x7684;&#x533A;&#x522B;&#x662F;Flutter Package&#x8868;&#x793A;&#x7EAF; Flutter &#x6A21;&#x5757;&#xFF0C;
&#x4E0D;&#x9700;&#x8981;&#x539F;&#x751F;&#x5F00;&#x53D1;&#xFF0C;&#x6CA1;&#x6709;Android &#x548C; iOS &#x9879;&#x76EE;&#xFF0C;&#x6BD4;&#x5982;&#x5F00;&#x53D1;&#x4E00;&#x4E2A;&#x7EAF; UI &#x7684;&#x63D2;&#x4EF6;&#x3002;
</code></pre>
<h3 id="flutter-module"><a name="flutter-module" class="anchor-navigation-ex-anchor" href="#flutter-module"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.4. Flutter Module</h3>
<pre><code>Flutter Module &#x7528;&#x4E8E;&#x539F;&#x751F;&#x9879;&#x76EE;&#x4E2D;&#x63D2;&#x5165; Flutter &#x6A21;&#x5757;&#xFF0C;&#x539F;&#x751F;&#x4E3A;&#x4E3B;&#x4F53;&#xFF0C;&#x4E0E; Flutter &#x8FDB;&#x884C;&#x6DF7;&#x5408;&#x5F00;&#x53D1;&#x3002;
</code></pre><h2 id="json"><a name="json" class="anchor-navigation-ex-anchor" href="#json"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. json</h2>
<pre><code class="lang-text">// &#x4E3E;&#x4F8B;&#x4F7F;&#x7528;
// json.decode(modelStr)
// Parses the string and returns the resulting Json object

//  json obj &#x8F6C;&#x5BF9;&#x8C61;
WeatherModelEntity weatherModelEntity = WeatherModelEntity().fromJson(json.decode(modelStr));

------------------
 json&#x90E8;&#x5206;&#x7684;&#x4EE3;&#x7801;&#x4F7F;&#x7528; FlutterJsonBeanFactory &#x63D2;&#x4EF6;&#x751F;&#x6210;&#x7684; &#x3002;
 https://plugins.jetbrains.com/plugin/11415-flutterjsonbeanfactory

&#x5982;&#x679C;&#x6539;&#x53D8;&#x4E86;&#x7ED3;&#x6784;&#xFF0C;&#x9700;&#x8981;&#x5728;&#x53D8;&#x52A8;&#x8FC7;&#x7684;&#x6587;&#x4EF6;&#x4E0A; alt+ j &#x91CD;&#x65B0;&#x751F;&#x6210; json_convert_content.dart

------------------
1&#x3001;&#x5C06; json &#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x4E3A; map &#x683C;&#x5F0F;&#x7684;json &#x5BF9;&#x8C61; 
import &apos;dart:convert&apos;; //&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;

2&#x3001;&#x5C06; json &#x5BF9;&#x8C61;&#x8F6C;&#x4E3A; &#x5B9E;&#x4F53;&#x7C7B;&#x5BF9;&#x8C61; 
&#x501F;&#x52A9;&#x7B2C;&#x4E09;&#x65B9;&#x5DE5;&#x5177; FlutterJsonBeanFactory &#x7B80;&#x5316;&#x4EBA;&#x5DE5;&#x4EE3;&#x7801;
</code></pre>
<h2 id="&#x7B7E;&#x540D;&#x914D;&#x7F6E;-keystore"><a name="&#x7B7E;&#x540D;&#x914D;&#x7F6E;-keystore" class="anchor-navigation-ex-anchor" href="#&#x7B7E;&#x540D;&#x914D;&#x7F6E;-keystore"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x7B7E;&#x540D;&#x914D;&#x7F6E; keystore</h2>
<pre><code class="lang-text">&#x8DDF;Android &#x5DE5;&#x7A0B; &#x4E00;&#x6837;&#x914D;&#x7F6E;&#x5373;&#x53EF;&#x3002;
</code></pre>
<h2 id="&#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;"><a name="&#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x5F15;&#x5165;&#x672C;&#x5730;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;</h2>
<pre><code class="lang-text">1&#x3001;&#x5728;&#x5DE5;&#x7A0B;&#x76EE;&#x5F55;&#x4E0B;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x5B58;&#x653E;&#x63D2;&#x4EF6;&#xFF0C;&#x6BD4;&#x5982;plugin
2&#x3001;&#x6253;&#x5F00;&#x5DE5;&#x7A0B;&#x7684;pubspec.yaml&#xFF0C;&#x5728;dependence&#x91CC;&#x6DFB;&#x52A0;plugin&#x4E0B;&#x7684;&#x63D2;&#x4EF6;
//&#x672C;&#x5730;&#x63D2;&#x4EF6;&#x5F15;&#x7528; &#x6CE8;&#x610F;&#x7F29;&#x8FDB;&#x683C;&#x5F0F;
  webview_flutter:
    path: plugin/webview_flutter
</code></pre>
<h2 id="flutter&#x5DE5;&#x7A0B;&#x4E2D;-android&#x90E8;&#x5206;&#x7206;&#x7EA2;"><a name="flutter&#x5DE5;&#x7A0B;&#x4E2D;-android&#x90E8;&#x5206;&#x7206;&#x7EA2;" class="anchor-navigation-ex-anchor" href="#flutter&#x5DE5;&#x7A0B;&#x4E2D;-android&#x90E8;&#x5206;&#x7206;&#x7EA2;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. flutter&#x5DE5;&#x7A0B;&#x4E2D; Android&#x90E8;&#x5206;&#x7206;&#x7EA2;</h2>
<pre><code class="lang-text">&#x5982;&#x679C;&#x5DE5;&#x7A0B;&#x80FD;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#xFF0C;&#x8BF7;&#x4E0D;&#x8981;&#x7406;&#x4F1A;&#x3002;
&#x7F16;&#x5199;Android&#x90E8;&#x5206;&#x4EE3;&#x7801;&#x65F6;&#x4F60;&#x91CD;&#x65B0;&#x7528;Androidstudio&#x6253;&#x5F00;Android&#x90E8;&#x5206;&#x5373;&#x53EF;&#xFF0C;&#x5B83;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;Android&#x5DE5;&#x7A0B;&#x3002;

// &#x5982;&#x679C;&#x662F; build.gradle &#x4E2D; Properties &#x3001;GradleException  &#x7206;&#x7EA2; 
&#x6309;&#x7167;&#x63D0;&#x793A;&#x5F15;&#x5165; sdk &#xFF0C;&#x5E76;&#x5C06; GradleException &#x6539;&#x6210; Exception &#xFF0C;&#x7136;&#x540E;&#x91CD;&#x65B0;&#x5237;&#x65B0;&#x5DE5;&#x7A0B;&#x5373;&#x53EF;&#x3002;
</code></pre>
<h2 id="flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;-android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;"><a name="flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;-android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;" class="anchor-navigation-ex-anchor" href="#flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;-android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. flutter &#x63D2;&#x4EF6;&#x5F00;&#x53D1; Android&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7206;&#x7EA2;</h2>
<pre><code class="lang-text">&#x5728;Android&#x7684; build.gradle&#x4E0B;&#x52A0;&#x5165;&#x4EE5;&#x4E0B;&#x914D;&#x7F6E;&#xFF0C;&#x5F15;&#x5165; flutter.jar&#x5373;&#x53EF;&#x3002;
//&#x83B7;&#x53D6;local.properties&#x914D;&#x7F6E;&#x6587;&#x4EF6;
def localProperties = new Properties()
def localPropertiesFile = rootProject.file(&apos;local.properties&apos;)
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader(&apos;UTF-8&apos;) { reader -&gt;
        localProperties.load(reader)
    }
}
//&#x83B7;&#x53D6;flutter&#x7684;sdk&#x8DEF;&#x5F84;
def flutterRoot = localProperties.getProperty(&apos;flutter.sdk&apos;)
if (flutterRoot == null) {
    throw new GradleException(&quot;Flutter SDK not found. Define location with flutter.sdk in the local.properties file.&quot;)
}

dependencies {
    compileOnly files(&quot;$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar&quot;)
}
</code></pre>
<h2 id="flutter-&#x4E0E;-android-&#x6570;&#x636E;-&#x4EA4;&#x4E92;"><a name="flutter-&#x4E0E;-android-&#x6570;&#x636E;-&#x4EA4;&#x4E92;" class="anchor-navigation-ex-anchor" href="#flutter-&#x4E0E;-android-&#x6570;&#x636E;-&#x4EA4;&#x4E92;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. flutter &#x4E0E; Android &#x6570;&#x636E; &#x4EA4;&#x4E92;</h2>
<p>&#x6709;&#x4E9B;&#x529F;&#x80FD;&#xFF0C;flutter&#x6682;&#x65F6;&#x4E0D;&#x652F;&#x6301;(&#x4F8B;&#x5982;&#x84DD;&#x7259;)&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x7528;Android&#x5F00;&#x53D1;&#x83B7;&#x5F97;&#x6570;&#x636E;&#xFF0C;&#x7136;&#x540E;&#x4F20;&#x9012;&#x7ED9;&#x84DD;&#x7259;&#x3002;</p>
<pre><code class="lang-text">flutter&#x548C;Android&#x901A;&#x4FE1;&#x7684;&#x65B9;&#x5F0F;&#x76EE;&#x524D;&#x4E3B;&#x8981;&#x53EF;&#x4EE5;&#x91C7;&#x7528;
MethodChannel // flutter&#x8C03;&#x7528;&#x65B9;&#x6CD5;&#xFF0C;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#xFF0C;&#x4E00;&#x95EE;&#x4E00;&#x7B54;&#x6A21;&#x5F0F;
EventChannel // Android&#x7AEF;&#x4E0D;&#x65AD;&#x5F80;flutter&#x53D1;&#x9001;&#x6570;&#x636E; &#xFF0C;&#x5355;&#x5411;?
BasicMessageChannel // &#x53CC;&#x5411;&#x901A;&#x4FE1;

&#x6CE8;&#x610F;&#xFF1A;&#x65B0;&#x5EFA;&#x901A;&#x9053;&#x5BF9;&#x8C61;&#x65F6; &#xFF0C;flutter &#x548C; Android &#x7AEF;&#xFF0C;name &#x53C2;&#x6570;&#x662F;&#x5BF9;&#x5E94;&#x7684;&#xFF0C;

public class MainActivity extends FlutterActivity  implements MethodChannel.MethodCallHandler {
    int count = 0;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Activity activity = this ;

        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    if(eventSink==null){
                        WkLog.showLog(&quot;myEvent ==null&quot;);
                    }else{
                        count ++ ;
                        activity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if(count%2==0){
                                    eventSink.success(&quot;hello android...&quot;+count);
                                }else{
                                    eventSink.error(&quot;500&quot; ,&quot;&#x53D1;&#x751F;&#x5F02;&#x5E38;&quot; ,null);
                                }
                            }
                        });
                    }


                    if(basicMessageChannel!=null){
                        activity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                               basicMessageChannel.send(&quot;Android&#x4E3B;&#x52A8;&#x53D1;&#x9001;&#x6D88;&#x606F; &quot; + count);
                            }
                        });

                    }else{
                        WkLog.showLog(&quot;basicMessageChannel ==null&quot;);
                    }


                }
            }
        }).start();
    }

    private final String KEY_METHODCHANNEL =&quot;KEY_METHODCHANNEL_20201124&quot; ;
    private final String KEY_EventChannel =&quot;KEY_EventChannel_20201124&quot; ;
    private final String KEY_BasicMessageChannel =&quot;BasicMessageChannel_20201124&quot; ;
    private MethodChannel methodChannel;
    private  EventChannel.EventSink eventSink = null ;
    private BasicMessageChannel&lt;String&gt; basicMessageChannel;

    //  configureFlutterEngine &#x51FD;&#x6570; &#x5728; onCreate &#x4E4B;&#x524D;&#x6267;&#x884C;
    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);
        initEngineConfig(flutterEngine);
    }

    private void initEngineConfig(FlutterEngine flutterEngine){
        // MethodChannel
        methodChannel = new MethodChannel(flutterEngine.getDartExecutor(), KEY_METHODCHANNEL);
        methodChannel.setMethodCallHandler(this);

        // EventChannel
        EventChannel eventChannel =new EventChannel( flutterEngine.getDartExecutor() ,KEY_EventChannel);
        eventChannel.setStreamHandler( new EventChannel.StreamHandler() {
            @Override
            public void onListen(Object arguments, EventChannel.EventSink events) {
                // events &#x4F20;&#x51FA;&#x53BB;&#xFF0C;&#x7528;&#x6765;&#x4E3B;&#x52A8;&#x53D1;&#x9001;&#x6570;&#x636E;
                eventSink =events ;
            }

            @Override
            public void onCancel(Object arguments) {

            }
        });

        //
        basicMessageChannel = new BasicMessageChannel&lt;String&gt; (  flutterEngine.getDartExecutor() ,
                KEY_BasicMessageChannel, StringCodec.INSTANCE); // StandardMessageCodec.INSTANCE
        basicMessageChannel.setMessageHandler( new BasicMessageChannel.MessageHandler() {
            @Override
            public void onMessage(Object message,  BasicMessageChannel.Reply reply){
                String str =  (String) message;
                WkLog.showLog(&quot;&#x6536;&#x5230;&#x6765;&#x81EA;flutter=&quot;+ str);

            }
        });
    }

    @Override
    public void onMethodCall(MethodCall call, MethodChannel.Result result) {
        if (call.method.equals(&quot;userLogin&quot;)) {
            String hostIp = call.argument(&quot;hostIp&quot;);
            String hostPort = call.argument(&quot;hostPort&quot;);
            result.success(hostIp+ &quot;   &quot;+hostPort + &quot;&#x767B;&#x5F55;&#x6210;&#x529F;...&quot; + System.currentTimeMillis()) ;
        }else {
            result.notImplemented();
        }
    }
}


class MsgTransmissionTool {
  static String KEY_METHODCHANNEL =&quot;KEY_METHODCHANNEL_20201124&quot; ;
  static String KEY_EventChannel =&quot;KEY_EventChannel_20201124&quot; ;
  static String KEY_BasicMessageChannel =&quot;BasicMessageChannel_20201124&quot; ;

  static MsgTransmissionTool _instance ;
  static MsgTransmissionTool getinstance()  {
    if(_instance ==null){
      _instance = MsgTransmissionTool() ;
    }
    return _instance ;
  }

  MethodChannel methodChannel ;
  EventChannel eventChannel  ;
  BasicMessageChannel basicMessageChannel ;
  MsgTransmissionTool(){
    // todo &#x91CD;&#x8981;&#x6CE8;&#x91CA;&#xFF1A; &#x8981;&#x5148;&#x5728; flutter&#x7AEF;&#x65B0;&#x5EFA;&#x521D;&#x59CB;&#x5316;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#xFF0C;&#x5426;&#x5219;Android&#x7AEF;&#x7684;&#x90A3;&#x4E9B;&#x5BF9;&#x8C61;&#x662F;&#x7A7A;&#x7684;&#x3002;
    methodChannel =   MethodChannel(KEY_METHODCHANNEL);
    eventChannel = EventChannel(KEY_EventChannel );
    basicMessageChannel = BasicMessageChannel( KEY_BasicMessageChannel, StringCodec());
    // StandardMessageCodec
  }

  setMessageHandler(  Future&lt;dynamic&gt; Function( dynamic message)  handler ){
    if(basicMessageChannel!=null){
      basicMessageChannel.setMessageHandler(handler) ;
    }
  }

  setEnventChannelListener( void onData(dynamic event) ,void _onError(dynamic event) ){
    if(eventChannel!=null){
      eventChannel.receiveBroadcastStream().listen( onData, onError: _onError);
    }
  }

  void sendMsgByBasicMessageChannel(String msg) async {
    if(basicMessageChannel!=null){
       await basicMessageChannel.send(msg );
    }
  }

  Future&lt;String&gt; sendMsgByMethodChannel( String hostIp ,String hostPort)  async {
    if(methodChannel!=null){
      final String version =
      // &#x53C2;&#x6570;&#x4EE5;&#x952E;&#x503C;&#x5BF9;&#x7684;&#x65B9;&#x5F0F;&#x4F20;&#x9012;&#x8FC7;&#x53BB;
      await methodChannel.invokeMethod(&apos;userLogin&apos;  , &lt;String,dynamic&gt;{&quot;hostIp&quot;:hostIp , &quot;hostPort&quot;:hostPort});
      return version;
    }else{
      print(&quot;methodChannel ==null&quot;);
    }
    return null ;
  }
}
</code></pre>
<pre><code class="lang-text">// &#x4F7F;&#x7528;
  // &#x8BBE;&#x7F6E;&#x76D1;&#x542C;&#x51FD;&#x6570;
  _initTool() async{
    await MsgTransmissionTool.getinstance().setMessageHandler(  ongetMsgFromMessageChannerl);
    await MsgTransmissionTool.getinstance().setEnventChannelListener(  _onEvent , _onError);
  }

  void _onEvent(Object event) {
    setState(() {
      msg2 = event ;
    });
    print(&quot;&#x6536;&#x5230;&#x6570;&#x636E;==_onEvent==$event&quot;);
  }

  void _onError(Object error) {
    PlatformException exception = error ;
    setState(() {
      msg2 = &quot; ${ exception.message} , ${exception.code} &quot;;
    });
    print(&quot;&#x6536;&#x5230;&#x6570;&#x636E;==_onError&quot;);
  }

  Future&lt;String&gt; ongetMsgFromMessageChannerl( dynamic message)  {
  setState(() {
    msg3= message ;
  });
  }

// &#x5F80;Android&#x53D1;&#x9001;&#x6570;&#x636E;
Future&lt;void&gt; testSend() async {
String  result = await MsgTransmissionTool.getinstance().sendMsgByMethodChannel(&quot;192.168.1.1&quot; ,&quot;8080&quot;);
setState(() {
  loginResult=result ;
});

MsgTransmissionTool.getinstance().sendMsgByBasicMessageChannel(&quot;BasicMessageChannel &#x7ED9;Android &#x53D1;&#x9001;&#x6D88;&#x606F;&quot;) ;
}
</code></pre>
<h2 id="flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;"><a name="flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;" class="anchor-navigation-ex-anchor" href="#flutter-&#x63D2;&#x4EF6;&#x5F00;&#x53D1;"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. flutter &#x63D2;&#x4EF6;&#x5F00;&#x53D1;</h2>
<pre><code class="lang-text">1&#x3001;&#x65B0;&#x5EFA;&#x63D2;&#x4EF6;&#x5DE5;&#x7A0B;
2&#x3001;&#x8C03;&#x7528;&#x8005;&#x4E2D; &#x5F15;&#x5165;&#x63D2;&#x4EF6;&#x5730;&#x5740;
  wk_flutter_plugin:
    path: wk_flutter_plugin  # &#x672C;&#x5730;flutter&#x63D2;&#x4EF6;&#x5E93; msg_plugin
</code></pre>
<h2 id="flutter-&#x8C03;&#x7528;android&#x63A7;&#x4EF6;"><a name="flutter-&#x8C03;&#x7528;android&#x63A7;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#flutter-&#x8C03;&#x7528;android&#x63A7;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. flutter &#x8C03;&#x7528;Android&#x63A7;&#x4EF6;</h2>
<pre><code class="lang-text">// Android &#x7AEF; &#x65B0;&#x5EFA; View &#x548C;&#x5DE5;&#x5382;&#x7C7B;
class MyView implements PlatformView {
    private TextView textView;

    MyView(Context context ) {
        // configureFlutterEngine &#x51FD;&#x6570; &#x5728; onCreate &#x4E4B;&#x524D;&#x6267;&#x884C; &#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x80FD;&#x901A;&#x8FC7; findViewById &#x65B9;&#x5F0F;&#x83B7;&#x5F97;&#x63A7;&#x4EF6;
        //View rootView = inflater.inflate(R.layout.testlayout, null);
        //rootView.findViewById()
        TextView myNativeView = new TextView(context);
        myNativeView.setTextColor(Color.RED);
        myNativeView.setClickable(true);
        myNativeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                textView.setTextColor(Color.BLUE);
                Toast.makeText(context ,&quot;hello android&quot; ,Toast.LENGTH_SHORT).show();
            }
        });
        this.textView = myNativeView;
    }

    public void updateValue(String value){
        textView.setTextColor(Color.RED);
        textView.setText(&quot;----&gt; &quot;+value);
    }

    @Override
    public View getView() {
        return textView;
    }

    @Override
    public void dispose() {  }
}

public class MyViewFactory extends PlatformViewFactory {
    private MyView myView ;
    public MyViewFactory( ) {
        super(StandardMessageCodec.INSTANCE);
    }

    @Override
    public PlatformView create(Context context, int id, Object args) {
        myView = new MyView(context) ;
        // &#x65B0;&#x5EFA;&#x65F6; &#x4F20;&#x9012;&#x8FC7;&#x6765;&#x7684;&#x53C2;&#x6570;
        Map&lt;String ,String&gt; params = (Map&lt;String, String&gt;) args;
        String value = params.get(&quot;key123456&quot;) ;
        myView.updateValue(value);
        return myView;
    }
}

//  &#x5728;XXActivity&#x4E2D;  &#x6CE8;&#x518C;&#x8FD9;&#x4E2A;&#x63A7;&#x4EF6;
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    super.configureFlutterEngine(flutterEngine);
    PlatformViewRegistry registry = flutterEngine.getPlatformViewsController().getRegistry() ;
    myViewFactory =   new MyViewFactory() ;
    // platform_text_view12345678 &#x662F;&#x5168;&#x5C40;&#x552F;&#x4E00;&#x7684;&#xFF0C;&#x8981;&#x4E0E;flutter&#x7AEF;&#x5BF9;&#x5E94;&#x4F7F;&#x7528;
    registry.registerViewFactory(&quot;platform_text_view12345678&quot;,myViewFactory) ;
}

// flutter&#x7AEF; &#x901A;&#x8FC7; AndroidView &#x6765;&#x5305;&#x88F9;&#x8C03;&#x7528;
var androidView  =  AndroidView(
    viewType: &quot;platform_text_view12345678&quot;,
    creationParams: &lt;String, dynamic&gt;{&quot;key123456&quot;: &quot;&#x6211;&#x6765;&#x81EA;flutter&quot;},
    creationParamsCodec: const StandardMessageCodec());

Container(
  // width: 80,
  height: 80,
  child: androidView,
)  ,
</code></pre>
<h2 id="&#x56FD;&#x9645;&#x5316;-&#x7FFB;&#x8BD1;&#x652F;&#x6301;"><a name="&#x56FD;&#x9645;&#x5316;-&#x7FFB;&#x8BD1;&#x652F;&#x6301;" class="anchor-navigation-ex-anchor" href="#&#x56FD;&#x9645;&#x5316;-&#x7FFB;&#x8BD1;&#x652F;&#x6301;"><i class="fa fa-link" aria-hidden="true"></i></a>1.12. &#x56FD;&#x9645;&#x5316; &#x7FFB;&#x8BD1;&#x652F;&#x6301;</h2>
<h3 id="&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6;-&#x56FD;&#x9645;&#x5316;"><a name="&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6;-&#x56FD;&#x9645;&#x5316;" class="anchor-navigation-ex-anchor" href="#&#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6;-&#x56FD;&#x9645;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.1. &#x7CFB;&#x7EDF;&#x81EA;&#x5E26;&#x7684;&#x63A7;&#x4EF6; &#x56FD;&#x9645;&#x5316;</h3>
<p>Flutter&#x7ED9;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x7684;Widget&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x5C31;&#x662F;&#x652F;&#x6301;&#x56FD;&#x9645;&#x5316;&#x3002;&#x4F8B;&#x5982;&#x65F6;&#x95F4;&#x65E5;&#x671F;&#x9009;&#x62E9;&#x63A7;&#x4EF6;&#x3002;</p>
<pre><code class="lang-text">1&#x3001; pubspec.yaml&#x4E2D;&#x65B0;&#x589E;&#x914D;&#x7F6E;
  flutter_localizations: # &#x56FD;&#x9645;&#x5316;&#x652F;&#x6301; &#x5305;
    sdk: flutter

2&#x3001; &#x5BF9; MaterialApp &#x8FDB;&#x884C;&#x914D;&#x7F6E;
return MaterialApp(
  title: &apos;Flutter Demo&apos;,
  // localizationsDelegates &#x6307;&#x5B9A;&#x54EA;&#x4E9B;Widget&#x9700;&#x8981;&#x8FDB;&#x884C;&#x56FD;&#x9645;&#x5316;
  localizationsDelegates: [
    GlobalMaterialLocalizations.delegate, // Material
    GlobalCupertinoLocalizations.delegate, // Cupertino
    GlobalWidgetsLocalizations.delegate // Widgets
  ],
  //  supportedLocales &#x652F;&#x6301;&#x54EA;&#x4E9B; &#x8BED;&#x8A00;
  supportedLocales: [
    Locale(&quot;en&quot;),
    Locale(&quot;zh&quot;)
  ],
</code></pre>
<h3 id="&#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A;-&#x56FD;&#x9645;&#x5316;"><a name="&#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A;-&#x56FD;&#x9645;&#x5316;" class="anchor-navigation-ex-anchor" href="#&#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A;-&#x56FD;&#x9645;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.2. &#x81EA;&#x5B9A;&#x4E49;&#x63A7;&#x4EF6;&#x3001;&#x6587;&#x672C;&#x3001;&#x4FE1;&#x606F;&#x5C55;&#x793A; &#x56FD;&#x9645;&#x5316;</h3>
<p>&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#xFF0C;&#x662F;&#x9700;&#x8981;&#x5BF9;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x63A7;&#x4EF6;&#x6216;&#x4FE1;&#x606F;&#x7B49;&#x8FDB;&#x884C;&#x56FD;&#x9645;&#x5316;&#x3002;</p>
<pre><code class="lang-text">&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x5FEB;&#x901F;&#xFF0C;&#x4E00;&#x822C;&#x4F7F;&#x7528;&#x7B2C;&#x4E09;&#x65B9;&#x63D2;&#x4EF6; Flutter intl  &#x8FDB;&#x884C;&#x914D;&#x7F6E;&#x3002;

1&#x3001;&#x5B89;&#x88C5;&#x63D2;&#x4EF6;&#xFF0C;&#x91CD;&#x542F; Androidstudio
2&#x3001; pubspec.yaml&#x4E2D;&#x65B0;&#x589E;&#x914D;&#x7F6E;
  flutter_localizations: # &#x56FD;&#x9645;&#x5316;&#x652F;&#x6301; &#x5305;
    sdk: flutter
3&#x3001;&#x5728;Tools&#x680F;&#x76EE;&#x4E0B;&#x627E;&#x5230; Flutter Intl &#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#x3002;
&#x521D;&#x59CB;&#x5316;&#x540E; &#xFF0C;
pubspec.yaml &#x4E2D;&#x4F1A;&#x65B0;&#x589E;&#x914D;&#x7F6E; flutter_intl:  enabled: true
lib &#x76EE;&#x5F55;&#x4E0B; &#x4F1A;&#x65B0;&#x589E; generated &#x3001;l10n&#x6587;&#x4EF6;&#x5939;

4&#x3001;&#x5728;Tools&#x680F;&#x76EE;&#x4E0B;&#x627E;&#x5230; Flutter Intl &#x6DFB;&#x52A0;&#x8BED;&#x8A00;&#x652F;&#x6301; &#xFF0C;&#x4F8B;&#x5982; en_IN, zh_CN, de_DE
5&#x3001;&#x5728; l10n &#x76EE;&#x5F55;&#x4E0B; &#x627E;&#x5230;&#x5BF9;&#x5E94;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x8FDB;&#x884C;&#x8BED;&#x8A00;&#x914D;&#x7F6E; &#xFF0C;&#x4F8B;&#x5982;
{
     &quot;string_title&quot;: &quot;&#x6D4B;&#x8BD5;&#x6807;&#x9898;&quot; ,
     &quot;string_Name&quot;: &quot;&#x6D4B;&#x8BD5;&#x540D;&#x5B57;&quot;
}

6&#x3001; &#x5728; MaterialApp &#x4E2D;&#x8FDB;&#x884C;&#x591A;&#x8BED;&#x8A00;&#x652F;&#x6301;&#x914D;&#x7F6E; &#x3002;
return MaterialApp(
  title: &quot;123123&quot;, // &#x5FEB;&#x7167;&#x4E0A;&#x663E;&#x793A;&#x7684;APP&#x540D;&#x5B57;
  // title: S.of(context).string_title, // &#x8FD9;&#x91CC;&#x4F7F;&#x7528;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;
  localizationsDelegates: const [
    S.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate
  ],
  supportedLocales: S.delegate.supportedLocales,
  localeListResolutionCallback: (locales, supportedLocales) {
    // &#x8BBE;&#x5907;&#x652F;&#x6301;&#x7684;&#x8BED;&#x8A00;
    print(&quot;---------$locales&quot;);
    return;
  },

7&#x3001;&#x4F7F;&#x7528;
Text( S.of(context).string_title )  // S&#x662F;&#x81EA;&#x5B9A;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x540D;
Text( S.current.string_title )
</code></pre>
<h2 id="&#x5C4F;&#x5E55;&#x9002;&#x914D;"><a name="&#x5C4F;&#x5E55;&#x9002;&#x914D;" class="anchor-navigation-ex-anchor" href="#&#x5C4F;&#x5E55;&#x9002;&#x914D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13. &#x5C4F;&#x5E55;&#x9002;&#x914D;</h2>
<pre><code class="lang-text">final mediaQueryData = MediaQuery.of(context);
// &#x903B;&#x8F91;&#x5BBD;&#x9AD8;
final screenWidth = mediaQueryData.size.width;
final screenHeight = mediaQueryData.size.height;
// &#x7269;&#x7406;&#x5BBD;&#x9AD8;&#x3001;&#x5206;&#x8FA8;&#x7387;
final physicalWidth = window.physicalSize.width; // import &apos;dart:ui&apos;;
final physicalHeight = window.physicalSize.height;
// &#x5BC6;&#x5EA6;
final dpr = window.devicePixelRatio;
// &#x72B6;&#x6001;&#x680F;&#x9AD8;&#x5EA6;
final statusBarHeight = mediaQueryData.padding.top;
// &#x5E95;&#x90E8;&#x9AD8;&#x5EA6;
final bottomHeight = mediaQueryData.padding.bottom;

flutter&#x7684;&#x957F;&#x5EA6;&#x5355;&#x4F4D;&#x662F; dp &#xFF0C;&#x800C;&#x4E0D;&#x662F;px ,&#x9002;&#x914D;&#x65B9;&#x6848;&#x53C2;&#x8003;Android&#x7684;&#x9002;&#x914D;&#x7ECF;&#x9A8C;&#x5373;&#x53EF;&#x3002;

&#x65E0;&#x8BBA;&#x8BBE;&#x8BA1;&#x7A3F;&#x7684;&#x5355;&#x4F4D;&#x662F;px,&#x6216;&#x8005;&#x662F;dp,&#x6211;&#x4EEC;&#x90FD;&#x80FD;&#x591F;&#x8F6C;&#x6362;&#x6210;px&#x3002;
1&#x3001;&#x5148;&#x5C06;&#x8BBE;&#x8BA1;&#x7A3F;&#x6362;&#x6210; dp&#x4E3A;&#x5355;&#x4F4D;&#x7684;&#x8BBE;&#x8BA1;&#x7A3F;
&#x4F8B;&#x5982; 1920 * 1080   ( px )
2&#x3001;&#x8F6C;&#x6362;&#x539F;&#x7406;(&#x6BD4;&#x4F8B;&#x4E00;&#x6837;)&#x5982;&#x56FE;.
</code></pre>
<p><img src="../pics/&#x9002;&#x914D;&#x65B9;&#x6848;.png" alt=""></p>
<h2 id="flutter-&#x8FD0;&#x884C;&#x6A21;&#x5F0F;"><a name="flutter-&#x8FD0;&#x884C;&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#flutter-&#x8FD0;&#x884C;&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.14. flutter &#x8FD0;&#x884C;&#x6A21;&#x5F0F;</h2>
<pre><code class="lang-text">release  //&#x53D1;&#x5E03;&#x6A21;&#x5F0F;
profile // &#x6027;&#x80FD;&#x6A21;&#x5F0F;
debug  // &#x8C03;&#x8BD5;&#x6A21;&#x5F0F;

flutter run --release
flutter run --debug

// It&apos;s likely that this file was generated under xxx \build, but the tool couldn&apos;t find it.
&#x8FD9;&#x4E2A;&#x95EE;&#x9898; &#x6211;&#x8FD9;&#x8FB9;&#x5BFC;&#x81F4;&#x7684;&#x539F;&#x56E0;&#x662F; &#x7B7E;&#x540D;&#x4FE1;&#x606F;&#x914D;&#x7F6E;&#x9519;&#x4E86; &#xFF0C; &#x4E0D;&#x80FD;&#x6539;&#x6210; wk2017&#x4E4B;&#x7C7B;&#x7684; &#xFF0C; &#x8981;&#x7528; release &#x6216;&#x8005;debug &#xFF0C; &#x6216;&#x8005;&#x5E72;&#x8106;&#x4E0D;&#x8981;&#x7B7E;&#x540D;&#x3002;

Androidstudio &#x83DC;&#x5355;&#x4E0B;&#x7684; Flutter fun xxx.dart in release/profile mode &#x3002;
</code></pre>
<h2 id="&#x72B6;&#x6001;&#x7BA1;&#x7406;"><a name="&#x72B6;&#x6001;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x72B6;&#x6001;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15. &#x72B6;&#x6001;&#x7BA1;&#x7406;</h2>
<pre><code class="lang-text">1&#x3001;&#x6DFB;&#x52A0;&#x652F;&#x6301; provider: ^4.3.2+2
https://pub.flutter-io.cn/packages/provider/install

2&#x3001;&#x5B9A;&#x4E49;&#x5171;&#x4EAB;&#x6570;&#x636E;&#x7C7B; xxx extends ChangeNotifier
notifyListeners(); // &#x901A;&#x77E5;&#x5237;&#x65B0;

3&#x3001;ChangeNotifierProvider &#x5C06;&#x6570;&#x636E;&#x5171;&#x4EAB;&#x7C7B; &#x548C; widget &#x5173;&#x8054;&#x8D77;&#x6765;
Widget someWidget = ChangeNotifierProvider&lt;GlobalModel&gt;(
      create: (context) =&gt; GlobalModel(), //  ChangeNotifier
      child: child, // Widget
    );

4&#x3001;&#x66F4;&#x65B0;&#x6570;&#x636E;
var shareBean = Provider.of&lt;XXX&gt;(context); // &#x5982;&#x679C; Widget &#x548C;  ChangeNotifier &#x6CA1;&#x6709;&#x5173;&#x8054;&#x8FC7;&#xFF0C;&#x662F;&#x4E0D;&#x662F;&#x5C31;&#x662F;null&#xFF1F;
shareBean.xxx = &quot;abc&quot; // &#x66F4;&#x65B0;&#x6570;&#x636E;
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-12-01 10:55:30
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../" class="navigation navigation-prev " aria-label="Previous page: 个人信息">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="flutter语法.html" class="navigation navigation-next " aria-label="Next page: flutter">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"flutter配置","level":"1.2","depth":1,"next":{"title":"flutter","level":"1.3","depth":1,"path":"chinese/flutter语法.md","ref":"chinese/flutter语法.md","articles":[]},"previous":{"title":"个人信息","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","donate","local-video","splitter","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/flutter配置.md","mtime":"2020-12-01T02:55:30.964Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-01T08:13:35.355Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

